package Thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-07-29
 * Time: 21:37
 */
public class demo11 {
    public static void main(String[] args) throws InterruptedException {
        Thread a = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                System.out.println("线程a");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("线程a执行完毕");
        });
        a.start();
        Thread.sleep(4000);
        System.out.println("主线程等待开始");
        a.join();
        System.out.println("主线程等待结束");
    }
}
